package liming.ai.code.v4.data;


import java.io.File;
import java.util.Objects;

public class FileInfo extends BaseConfig{
    private final String packageName;
    private final String className;

    private final File javaFile;
    private final File classFile;
    private final File mdFile;

    private int version;


    public FileInfo(String packageName,String className){
        this.packageName=packageName;
        this.className=className;
        String path = packageName.replace(".",File.separator)+File.separator+className;
        javaFile = new File(getJavasPath(),path+".java");
        classFile = new File(getClassesPath(),path+".class");
        mdFile = new File(getMdsFilePath(),path+".md");
    }

    public File getJavaFile() {
        return javaFile;
    }

    public File getClassFile() {
        return classFile;
    }

    public File getMdFile() {
        return mdFile;
    }

    public String getPackage(){
        return packageName;
    }
    public String getClassName(){
        return className;
    }
    public String getAllClassName() {
        return packageName+"."+className;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FileInfo fileInfo = (FileInfo) o;
        return packageName.equals(fileInfo.packageName) && className.equals(fileInfo.className);
    }

    @Override
    public int hashCode() {
        return Objects.hash(packageName, className);
    }

    @Override
    public String toString() {
        return getBaseInfo()+"FileInfo{" +
                "packageName='" + packageName + '\'' +
                ", className='" + className + '\'' +
                ", javaFile=" + javaFile +
                ", classFile=" + classFile +
                ", mdFile=" + mdFile +
                ", version= "+ version +
                '}'+"\n";
    }
}
